package com.loeng.module.system.controller.admin.dict;

import com.loeng.framework.common.pojo.CommonResult;
import com.loeng.framework.common.util.object.BeanUtils;
import com.loeng.module.system.controller.admin.dict.vo.type.DictTypeSimpleRespVO;
import com.loeng.module.system.dal.dataobject.dict.DictTypeDO;
import com.loeng.module.system.service.dict.DictTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

import static com.loeng.framework.common.pojo.CommonResult.success;

/**
 * 字典类型
 *
 * @author loeng zhuo
 */
@Tag(name = "管理后台 - 字典类型")
@RestController
@RequestMapping("/system/dict-type")
@Validated
public class DictTypeController {

    @Resource
    private DictTypeService dictTypeService;

    @GetMapping(value = {"/list-all-simple", "simple-list"})
    @Operation(summary = "获得全部字典类型列表", description = "包括开启 + 禁用的字典类型，主要用于前端的下拉选项")
    public CommonResult<List<DictTypeSimpleRespVO>> getSimpleDictTypeList() {
        List<DictTypeDO> list = dictTypeService.getDictTypeList();
        return success(BeanUtils.toBean(list, DictTypeSimpleRespVO.class));
    }

}
